package com.huzz.util.desin.flyweight;

/**
 * 享元模式
 */
class Client {
    public static void main(String[] args) {
        Train train1 = TrainFactory.getTrain("G10", 1000);
        Train train2 = TrainFactory.getTrain("G10", 1000);
        Train train3 = TrainFactory.getTrain("D22", 500);

        System.out.println(train1 == train2);  // true，train1和train2是同一个对象
        System.out.println(train1 == train3);  // false，train1和train3是不同的对象
    }
}